<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>新增患者</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css" th:href="@{/static/layui/css/layui.css}">

</head>

<!--完工-->

<body style="width: 800px;height: 600px;">
<!--编辑表单-->
<!--
    Integer id;//唯一主键
    String name;//姓名
    String studentNumber;//学号
    String sex;//性别
    String site;//隔离点定位
    String phone;//联系方式
    String illType;//病型
    Date haveIllTime;//开始发病时间
    Date isolatedBeginTime;//开始隔离时间
    String role;//角色担任（普通、寝室长、楼层长）
    Date changeTime;//此条数据被修改（增、改）的时间
-->
<div id="editBook">
    <form class="layui-form" id="saveBook" style="margin-top:10px">
        <input type="hidden" name="id" id="id">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">隔离者姓名</label>
                <div class="layui-input-inline">
                    <input type="text" name="name" id="name" required lay-verify="required" autocomplete="off"
                           class="layui-input" placeholder="必填">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">学号</label>
                <div class="layui-input-inline">
                    <input type="text" name="studentNumber" id="studentNumber" required lay-verify="identity" autocomplete="off"
                           class="layui-input" placeholder="必填">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">性别</label>
                <div class="layui-input-inline">
                    <select name ="sex" lay-filter="levelM" >
                        <option value ="男" checked="checked">男</option>
                        <option value ="女" >女</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">住处（楼号+层号+寝室号）</label>
                <div class="layui-input-inline">
                    <input type="text" name="site" id="site" required lay-verify="required" autocomplete="off"
                           class="layui-input" placeholder="必填">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">联系方式</label>
                <div class="layui-input-inline">
                    <input type="text" name="phone" id="phone" required lay-verify="phone" autocomplete="off"
                           class="layui-input" placeholder="必填">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">相关病型</label>
                <div class="layui-input-inline">
                    <select name ="illType" lay-filter="levelM" lay-verify="required">
                        <option value ="新冠肺炎" checked="checked">新冠肺炎</option>
                        <option value ="风疹" >风疹</option>
                        <option value ="黑热病" >黑热病</option>
                        <option value ="肺结核" >肺结核</option>
                        <option value ="病毒性肝炎" >病毒性肝炎</option>
                        <option value ="狂犬病" >狂犬病</option>
                        <option value ="伤寒" >伤寒</option>
                        <option value ="猩红热" >猩红热</option>
                        <option value ="登革热" >登革热</option>
                        <option value ="流行性感冒" >流行性感冒</option>
                    </select>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">开始发病日期</label>
                <div class="layui-input-inline">
                    <input type="date" name="haveIllTime" id="haveIllTime" required autocomplete="off"
                           class="layui-input"
                           lay-verify="date">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">开始隔离日期</label>
                <div class="layui-input-inline">
                    <input type="date" name="isolatedBeginTime" id="isolatedBeginTime" required autocomplete="off"
                           class="layui-input"
                           lay-verify="date">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">担任角色</label>
                <div class="layui-input-inline">
                    <select name ="role" lay-filter="levelM" lay-verify="required">
                        <option value ="普通" checked="checked">普通</option>
                        <option value ="寝室长" >寝室长</option>
<!--                        <option value ="楼层长" >楼层长</option>-->
                    </select>
                </div>
            </div>
        </div>

        <div class="layui-form-item" style="margin-top:40px" id="check">
            <div class="layui-input-block">
                <button class="layui-btn  layui-btn-submit " lay-submit="" lay-filter="saveBook">保存</button>
                <!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
            </div>
        </div>
    </form>
</div>


<script src="/static/js/jquery-1.11.3.min.js" th:src="@{/static/js/jquery-1.11.3.min.js}"></script>
<script src="/static/layui/layui.all.js" th:src="@{static/layui/layui.all.js}"></script>
<script src="/static/js/util.js" th:src="@{/static/js/util.js}"></script>

<!--ctx-->
<script th:replace="~{fragment::ctx}"/>

<script>
    var element, layer, laydate, form;

    $(function () {

        // 使用模块
        layui.use(['element', 'layer', 'laydate', 'form'], function () {
            element = layui.element;
            layer = layui.layer;
            laydate = layui.laydate;
            form = layui.form;
        });

        form.verify({
            integer:[
                /^[0-9]\d*$/
                ,'只能输入整数！'
            ],
            temperatureToday: function (value) {
                if (value.length === 4
                    &&value.charAt(2) === '.'
                    && value.charAt(0) <= '9'&& value.charAt(0) >= '0'
                    && value.charAt(1) <= '9'&& value.charAt(1) >= '0'
                    && value.charAt(3) <= '9'&& value.charAt(3) >= '0'){
                }else {
                    return '温度格式不合法！请按提示要求。';
                }
            },
            identity: function (value){
                    if(value.length === 12
                        && value.charAt(0) <= '9'&& value.charAt(0) >= '0'
                        && value.charAt(1) <= '9'&& value.charAt(1) >= '0'
                        && value.charAt(2) <= '9'&& value.charAt(2) >= '0'
                        && value.charAt(3) <= '9'&& value.charAt(3) >= '0'
                        && value.charAt(4) <= '9'&& value.charAt(4) >= '0'
                        && value.charAt(5) <= '9'&& value.charAt(5) >= '0'
                        && value.charAt(6) <= '9'&& value.charAt(6) >= '0'
                        && value.charAt(7) <= '9'&& value.charAt(7) >= '0'
                        && value.charAt(8) <= '9'&& value.charAt(8) >= '0'
                        && value.charAt(9) <= '9'&& value.charAt(9) >= '0'
                        && value.charAt(10) <= '9'&& value.charAt(10) >= '0'
                        && value.charAt(11) <= '9'&& value.charAt(11) >= '0'){
                    }else {
                        return '学号格式错误！（12位）';
                    }
            }
        });


        //监听表单提交
        // 修改
        form.on('submit(saveBook)', function (data) {
            //layer.alert(JSON.stringify(data.field));
            $.ajax({
                url: ctx+'api/isolatedMan/save',
                type: 'POST',
                contentType: "application/json",
                dataType: "json",
                data: JSON.stringify(data.field),
                success: function (result) {
                    if (result.code == 200) {
                        // layer.msg("修改成功！", {icon: 6});
                        cleanForm("#saveBook");
                        layer.closeAll();//关闭所有的弹出层
                        top.$(".layui-show").find("iframe")[0].contentWindow.userTable.reload();
                    } else {
                        layer.alert(result.message);
                    }
                }
            });

            return false;

        });
    });


</script>
</body>

</html>